package club.banyuan;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "Servlet1",urlPatterns = "/s1")
public class Servlet1 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String contentType = request.getContentType();
        System.out.println(contentType);

        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/plain;charset=utf-8");

        String username = request.getParameter("username");
        String password = request.getParameter("password");

        response.getWriter().println("username: " + username);
        response.getWriter().println("password: " + password);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        response.setContentType("text/plain;charset=UTF-8");
    }
}
